package mysql

import (
	"doctor-medicine-system/doctorrpc/doctorrpc"
	"gorm.io/gorm"
)

type MedSupply struct {
	gorm.Model
	DoctorId         int64  `gorm:"type:int(11);not null;comment:医生id"`
	MedSupplyName    string `gorm:"type:varchar(30);not null;comment:药品名称"`
	MedSupplyType    string `gorm:"type:varchar(30);not null;comment:药品规格"`
	MedSupplyAddress string `gorm:"type:varchar(30);not null;comment:生产商"`
	MedSupplyComment string `gorm:"type:varchar(30);not null;comment:注意事项"`
}

func (s *MedSupply) MedSupplyAdd(db *gorm.DB) error {
	return db.Debug().Create(s).Error
}
func MedSupplyList(db *gorm.DB, id int64) []*doctorrpc.MedSupplyList {
	var list []*doctorrpc.MedSupplyList
	db.Debug().Model(&MedSupply{}).
		Select(
			"med_supplies.id med_supply_id",
			"med_supply_name",
			"med_supply_type",
			"med_supply_address",
			"med_supply_comment",
		).Where("med_supplies.doctor_id=?", id).
		Find(&list)
	return list
}
